<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>asserts (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">testing.asserts</span>
</div>

<hr/>


  <h2>Classes</h2>
   
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>




  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.asserts.callWithoutLogging"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">callWithoutLogging<span class="args">(<span class="arg">fn</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Runs a function in an environment where test failures are not logged. This is
useful for testing test code, where failures can be a normal part of a test.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">fn</span>
        : <span class="type">function() : void</span>
        <div class="entryOverview">Function to run without logging failures.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line493">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.asserts.contains_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">contains_<span class="args">(<span class="arg">container</span>,&nbsp;<span class="arg">contained</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Tells whether the array contains the given element.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">container</span>
        : <span class="type">goog.testing.asserts.ArrayLike</span>
        <div class="entryOverview">The array to
    find the element in.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">contained</span>
        : <span class="type">*</span>
        <div class="entryOverview">Element to find.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether the element is in the array.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line1145">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.asserts.findDifferences"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">findDifferences<span class="args">(<span class="arg">expected</span>,&nbsp;<span class="arg">actual</span>,&nbsp;<span class="arg">opt_equalityPredicate</span>)</span>
        </span>
        &#8658; <span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
      </div>


     <div class="entryOverview">
       Determines if two items of any type match, and formulates an error message
if not.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">expected</span>
        : <span class="type">*</span>
        <div class="entryOverview">Expected argument to match.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">actual</span>
        : <span class="type">*</span>
        <div class="entryOverview">Argument as a result of performing the test.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_equalityPredicate</span>
        : (<span class="type">function(string, *, *): ?string)=</span>
        <div class="entryOverview">An optional
    function that can be used to check equality of variables. It accepts 3
    arguments: type-of-variables, var1, var2 (in that order) and returns an
    error message if the variables are not equal,
    goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL if the variables
    are equal, or
    goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS if the predicate
    couldn't check the input variables. The function will be called only if
    the types of var1 and var2 are identical.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>?</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&nbsp;
            Null on success, error message on failure.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line538">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.asserts.getDefaultErrorMsg_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">getDefaultErrorMsg_<span class="args">(<span class="arg">expected</span>,&nbsp;<span class="arg">actual</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">expected</span>
        : <span class="type">*</span>
        <div class="entryOverview">The expected value.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">actual</span>
        : <span class="type">*</span>
        <div class="entryOverview">The actual value.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&nbsp;
            A failure message of the values don't match.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line186">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.asserts.indexOf_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">indexOf_<span class="args">(<span class="arg">container</span>,&nbsp;<span class="arg">contained</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
      </div>


     <div class="entryOverview">
       Finds the position of the first occurrence of an element in a container.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">container</span>
        : <span class="type">goog.testing.asserts.ArrayLike</span>
        <div class="entryOverview">The array to find the element in.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">contained</span>
        : <span class="type">*</span>
        <div class="entryOverview">Element to find.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>&nbsp;
            Index of the first occurrence or -1 if not found.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line1122">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.asserts.isArrayIndexProp_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">isArrayIndexProp_<span class="args">(<span class="arg">prop</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Helper function for assertObjectEquals.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">prop</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">A property name.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            If the property name is an array index.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line1197">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.asserts.numberRoughEqualityPredicate_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">numberRoughEqualityPredicate_<span class="args">(<span class="arg">var1</span>,&nbsp;<span class="arg">var2</span>,&nbsp;<span class="arg">tolerance</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       Compares equality of two numbers, allowing them to differ up to a given
tolerance.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">var1</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">A number.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">var2</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">A number.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">tolerance</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Number">number</a></span>
        <div class="entryOverview">the maximum allowed difference.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether the two variables are sufficiently close.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line57">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.testing.asserts.raiseException"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">raiseException<span class="args">(<span class="arg">comment</span>,&nbsp;<span class="arg">opt_message</span>)</span>
        </span>
      </div>


     <div class="entryOverview">
       Raises a JsUnit exception with the given comment.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">comment</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">A summary for the exception.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_message</span>
        : <span class="type">string=</span>
        <div class="entryOverview">A description of the exception.</div>
     </td>
   </tr>
  </table>
      </div>
   
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line1181">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.testing.asserts.toArray_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">toArray_<span class="args">(<span class="arg">arrayLike</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>
      </div>


     <div class="entryOverview">
       Converts an array like object to array or clones it if it's already array.

     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">arrayLike</span>
        : <span class="type">goog.testing.asserts.ArrayLike</span>
        <div class="entryOverview">The collection.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array">Array</a></span>&nbsp;
            Copy of the collection as array.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line1105">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>



  <h2>Global Properties</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.testing.asserts.ArrayLike"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">ArrayLike</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line26">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>





  <a name="goog.testing.asserts.EQUALITY_PREDICATE_CANT_PROCESS"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">EQUALITY_PREDICATE_CANT_PROCESS</span>
        : 
     </div>


     <div class="entryOverview">
       The return value of the equality predicate passed to findDifferences below,
in cases where the predicate can't test the input variables for equality.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line511">Code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>





  <a name="goog.testing.asserts.EQUALITY_PREDICATE_VARS_ARE_EQUAL"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">EQUALITY_PREDICATE_VARS_ARE_EQUAL</span>
        : 
     </div>


     <div class="entryOverview">
       The return value of the equality predicate passed to findDifferences below,
in cases where the input vriables are equal.

     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line519">Code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry private">
       <td class="access"></td>





  <a name="goog.testing.asserts.primitiveRoughEqualityPredicates_"></a>

  <td>


     <div class="arg">
        <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.testing.asserts.</span><span class="entryName">primitiveRoughEqualityPredicates_</span>
        : 
     </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

  </td>


  <td class="view-code">
     <a href="local_closure_goog_testing_asserts.js.source.html#line67">Code &raquo;</a>
  </td>
     </tr>


  </table>
</div>
      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Package testing</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">Package Reference</h2>
            <div id="sideTypeIndex" rootPath="" current="testing.asserts"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
